package com.t.ArrayList;

import java.util.ArrayList;

public class ArrayListDemo {
    public static void main(String[] args) {
        ArrayList al = new ArrayList();
        Person p1 = new Person("徐龙","男",19,"202304060134","四班");
        al.add(p1);
        System.out.println("集合的长度为："+al.size());
        System.out.println(al.get(0));
        Person p;
        p=(Person) al.get(0);
        System.out.println("姓名："+p.name+"，性别："+p.gender+"，年龄："+p.age+"，学号："+p.number+"，班级："+p.Class);
        System.out.println("-----for循环-----");
        for (int i=0;i<al.size();i++){
            Person person=(Person) al.get(i);
            System.out.println("姓名："+person.name+"，性别："+person.gender+"，年龄："+person.age+"，学号："+person.number+"，班级："+person.Class);

        }
    }
}
